package view;

import entity.Color;
import service.OperatorServiceDaoImpl;
import tool.MyTool;

public class OperatorView {
    OperatorServiceDaoImpl operatorService = OperatorServiceDaoImpl.getOperatorService();

    public void OperatorMenu() throws Exception {
        while (true) {
            System.out.println(Color.getAnsiBlue() + Color.getAnsiReset());
            System.out.println("🔣-------~员工信息管理~--------------🔣");
            System.out.println("🐕-------<1.添加员工信息>------------*");
            System.out.println("🐖-------<2.查询员工信息>------------*");
            System.out.println("🐱-------<3.修改员工信息>------------*");
            System.out.println("🐱-------<4.删除员工信息>------*");
            System.out.println("🐕-------<5.退出>----------------*");
            char c = MyTool.selectMenu(5).charAt(0);
            switch (c) {
                case '1':
                    operatorService.insert();
                    break;
                case '2':
                    operatorSelectMenu();
                    break;
                case '3':
                    operatorService.update();
                    break;
                case '4':
                    operatorService.delete();
                    break;
                case '5':
                    return;
            }
        }
    }

    public void operatorSelectMenu() throws Exception {
        System.out.println(Color.getAnsiBlue() + Color.getAnsiReset());
        System.out.println("🔣-------~员工查询~----------------🔣");
        System.out.println("🐕-------<1.按编号查询>-------------*");
        System.out.println("🐖-------<2.按管理员查询>------------*");
        System.out.println("🐱-------<3.查询全部员工>------------*");
        System.out.println("🐱-------<4.退出>------*");
        char c = MyTool.selectMenu(4).charAt(0);
        switch (c) {
            case '1':
                operatorService.getOperatorById();
                break;
            case '2':
                operatorService.getOperatorByManager();
                break;
            case '3':
                operatorService.getOperatorAll();
                break;
            case '4':
                return;
        }
    }

    public static void main(String[] args) {
        OperatorView o = new OperatorView();
        while (true) {
            try {
                o.OperatorMenu();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}
